package com.dxl.producer;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Description: 生产者-主题模式
 *
 * @author: Yingyu Wei
 * <p>File Created at 2021/5/2</p>
 */
@Component
public class TopicProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Value("${mqlog.topic}")
    private String exchange;

    public void logMessage(String routingKey) {
        String msg = "主题匹配模式-时间：" + new Date();
        rabbitTemplate.convertAndSend(exchange, routingKey, msg);
    }
}
